<?php

   // require_once 'SqlHelper.class.php';
    $mysql = new SaeMysql();
	

    $data = $_POST['data'];
 
    $arr = json_decode($data,true);
 
    $i = 0;
    foreach ($arr as $key => $value) {
    	$info[$i]['key'] = $key;
    	$info[$i]['value'] = $value;
    	$i++;	
    }

     // $sqlHelper = new SqlHelper();
     for($j=0;$j<sizeof($arr);$j++){
     $sql = "update wx_lottery set wx_lottery_num = '".$info[$j]['value']."' where 
             wx_lottery_name = '".$info[$j]['key']."'";
    
     $mysql->runSql($sql);

     }

        $sql = "select * from wxC_lottery";
		$mysql->runSql($sql);

		$i = 0;
		$num = mysql_affected_rows();
        if($num != 0){
        	while($row = mysql_fetch_assoc($res)){
        		$arr[$i][wx_lottery_id] = $row[wx_lottery_id];
        		$arr[$i][wx_lottery_name] = $row[wx_lottery_name];
        		$arr[$i][wx_lottery_num] = $row[wx_lottery_num];
        		$i++;
        	}
        	//print_r($arr);
        	$json = json_encode($arr);
        	 echo $json;
        }else{
        	echo false;
        }
  
     //mysql_free_result($res);
?>